Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix buildLockKey failed #497

Merged
merged 2 commits into from
Mar 13, 2023
Merged

fix buildLockKey failed #497

merged 2 commits into from
Mar 13, 2023

Conversation

Charlie17Li
Copy link
Contributor

@Charlie17Li Charlie17Li commented Mar 4, 2023

What this PR does:

Which issue(s) this PR fixes:

Fixes #496

Special notes for your reviewer:

太长不看版
TableMeta 中获取的 PrimaryKey的 columns 顺序和实际 data 中 PrimaryKey 的 columns 顺序不一致导致类型转换发生错误

详细分析版

  1. buildLockKey 是用来生成 LockKey, 函数会扫描每一行并仅取出 primarykey,然后以此拼成 LockKey
  2. 取出每一行的 primarykey 中的值时,需要经过类型转换的过程,需要使用 类型 两个参数
  3. 类型 是从 TableMeta 中获取的,实际是通过 GetPrimaryKeyOnlyName 用来获取, PrimaryKey 中的 Columns 顺序随机
  4. 值 是 sqlRows 扫描每一行数据得到的 columns, 顺序是按照 TableMeta.ColumnNames 顺序
  5. 例如类型的顺序[id(int), order_id(varchar)], 而值的顺序是[order_id(varchar), id(int)] 就发生报错

Does this PR introduce a user-facing change?:


@github-actions github-actions bot added the coding label Mar 4, 2023
Signed-off-by: charlie <[email protected]>
Signed-off-by: charlie <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Mar 4, 2023

Codecov Report

Merging #497 (de0f14d) into master (39d8977) will decrease coverage by 0.03%.
The diff coverage is 0.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master     #497      +/-   ##
==========================================
- Coverage   39.05%   39.03%   -0.03%     
==========================================
  Files         152      152              
  Lines       10218    10225       +7     
==========================================
  Hits         3991     3991              
- Misses       5905     5912       +7     
  Partials      322      322              
Impacted Files Coverage Δ
pkg/datasource/sql/types/meta.go 31.11% <0.00%> (-5.74%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@Charlie17Li Charlie17Li changed the title fix buildKey failed fix buildLockKey failed Mar 4, 2023
@106umao 106umao requested a review from luky116 March 10, 2023 02:11
@luky116 luky116 merged commit 891b2f9 into apache:master Mar 13, 2023
georgehao pushed a commit to georgehao/seata-go that referenced this pull request May 7, 2023
sort before get column name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] Somtimes the select_for_update_executor_test.go/TestBuildLockKey test failed
4 participants